from flask import request, session
from flask_restful import Resource

from database import Database


# Mock user database

class remove(Resource):
    def post(self):
        db = Database()
        username = session.get('username')
        data = request.get_json()
        bookId = data.get('bookId')
        if id:
            db.execute_query("DELETE FROM cart WHERE bookId = %s AND userId = %s", (bookId, username))

            return {"message": "book delete from cart successfully"}, 200
        else:
            return {"message": "error"}, 404  # Changed return status to 409 Conflict
